package com.ai.study.utils;

import lombok.Data;

/**
 * reful接口响应结果
 *
 * @author wwei
 * @date 2025-02-23 23:00
 **/
@Data
public class AiResult<T> {
    private Integer code;
    private Integer subCode;
    private String msg;
    private String subMsg;
    private T data;

    public AiResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AiResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public AiResult(Integer code, Integer subCode, String msg,  String subMsg, T data) {
        this.code = code;
        this.subCode = subCode;
        this.msg = msg;
        this.subMsg = subMsg;
        this.data = data;
    }

    public static <T> AiResult<T> success(T data) {
        return new AiResult<>(0, "操作成功!", data);
    }
    public static <T> AiResult<T> error(Integer code, String msg) {
        return new AiResult<>(code, msg);
    }

}
